package cn.edu.cuit.elena.common;

public class SackConstants
{
    /**
     * Events.
     * */
    public static final String FAILURE = "0";
    public static final String SUCCESS = "1";
    public static final String DUPLICATED = "2";
    public static final String COMPLETE = "101";

    /**
     * Characters.
     * */
    public static final String EQUAL_SIGN = "=";
    public static final String DRIVER = "driver";
    public static final String USER_NAME = "username";
    public static final String PASS_WORD = "password";
    public static final String URL = "url";
    public static final String SCHEMA_NAME = "schemaname";
    public static final String DATASOURCE_ID = "datasourceid";
    public static final String DATASOURCE_STATE = "state";
    public static final String VENDER = "vender";
    public static final String FIELDS_DELIMITER = "'\\''";

    /**
     * Numbers.
     * */
    public static int MAX_CONNECTION_NUM = 10;
    public static int MIN_CONNECTION_NUM = 5;
    public static final int MONITOR_INTERVAL = 1000;

    /**
     * Pathes.
     * */
    public static final String USER_CONFIGURATION_FILE_ROOT_DIRECTORY = "userConf/";
    public static final String SYSTEM_CONFIGURATION = "system.ini";

    public enum DATABASE
    {
        //Currently, Elena just support ORACLE, MYSQL.
        ORACLE( 1 ), MYSQL( 2 );

        private int id;

        DATABASE(int id)
        {
            this.id = id;
        }

        public int id()
        {
            return id;
        }
    }

    /**
     * Sql
     * */
    public enum SQL
    {
        //        ELENA_USER_QUERYBYID( "SELECT * FROM ELENA.USER WHERE ELENA.USER.USERNAME = ?;" ),
        ELENA_USER_QUERYBYID( "select * from elena.user where elena.user.username = ?;" ), ELENA_USER_PRIVILEDGE_QUERYBYUSER(
            "select e.priviledge, e.urlname from (select * from elena.tc_priviledge c join elena.user_priviledge d where c.id = d.priviledge) e where e.user = ?;" ), GRANT_PRIVILEDGE_BY_ID(
            "insert into elena.user_priviledge (user,priviledge) values (?,?);" ), DEPRIVE_PRIVILEDGE_BY_ID(
            "delete c.* from elena.user_priviledge c where c.user = ? and c.priviledge = ? ;" ), CREATE_PIVILEDGE(
            "insert into elena.tc_priviledge (id,name,urlname,belongto) values(?,?,?,?);" ), ALL_PRIVILEDGE(
            "select c.id, c.name from elena.tc_priviledge c" ), LOAD_USER_MODULES_TREE(
            "select e.priviledge, e.name,e.urlname,e.belongto from (select * from elena.tc_priviledge c join elena.user_priviledge d where c.id = d.priviledge) e where e.user = ?" ), 
            SELECT_DATASOURCES_OF_USER(
            "select url, username, password,driver,datasourceid,vender,schemaname, state from elena.datasource where userid  = ?;" ), INSERT_DATASOURCE_OF_USER(
            " insert into datasource (userid,url,username,password,driver,state,schemaname,vender) values(?,?,?,?,?,?,?,?);" ), DELETE_DATASOURCE_OF_USER(
            "delete from elena.datasource where userid=? and username=? and url=? and password=? and driver = ?;" ), ADD_USER(
            "insert into user (username,password,usergroup,gender,comments) values (?,?,?,?,?);" ), UPDATE_USER(
            "update user set password = ?,usergroup = ?, gender = ?, comments = ? where username = ?" ), DELETE_USER(
            "delete from user where username = " );
        ;

        private String sql;

        SQL(String sql)
        {
            this.sql = sql;
        }

        public String sql()
        {
            return sql;
        }
    }

    /**
     * Env
     * */
    public static final String HADOOP_HOME = "HADOOP_HOME=/usr/local/development/hadoop-1.0.0";
    public static final String SQOOP_HOME = "SQOOP_HOME=/usr/local/development/sqoop-1.2.0-CDH3B4";
    public static final String HIVE_HOME = "HIVE_HOME=/usr/local/development/hive-0.8.1";

    /**
     * Work path
     * */
    public static final String SQOOP_BIN = "/usr/local/development/sqoop-1.2.0-CDH3B4/bin";
    public static final String HIVE_BIN = "/usr/local/development/hive-0.8.1/bin";
    public static final String HDFS_HIVE_TABLES_ROOT_DIR = "/user/quintus";

}
